# 示例数据
candidates = [2,3,5]
target = 8

def combination_sum(candidates,target):
    def dfs(start,path,remain):
        if remain == 0:
            result.append(path.copy())
            return
        for i in range(start, len(candidates)):
            if candidates[i] > remain:
                continue
            path.append(candidates[i])
            dfs(i,path,remain - candidates[i])
            path.pop()
    result = []
    dfs(0, [], target)
    return result

print(combination_sum(candidates, target))       
